www.gusucode.com > 基于马尔科夫随机场的图像分割matlab源码。包括ICM迭代条件模式求解最大后验概率算法 > code23/matlab MRF toy examples/states2image.m

    % function [im] = states2image(nodes);
% returns an image of ones for every node which is in the kth state.
% oct. 4, 2003 wtf created.

function[im] = states2image(nodes, kth, N, M);

iNode = 1;
im = zeros(N,M);
for j = 1:M
    for i = 1:N
        im(i,j) = nodes{iNode}.state == kth;
        iNode = iNode + 1;
    end
end